var app = getApp(), api = require('../../../../api.js');
Page({

  /**
   * 页面的初始数据
   */
  data: {

  },
  onShow: function () {
    this.mylist();

  },
  mylist: function () {
    var that = this;
    app.request({
      url: api.default.cardList,
      data: {
        uid: wx.getStorageSync('uid'),
        bid: wx.getStorageSync('bid')
      },
      success: function (e) {
        that.setData({
          data: e.data
        })
      }
    })
  }
  ,
  bankSetup: function (e) {
    var that = this;
    let _id = e.currentTarget.dataset.id;
    // TODO 发送请求
    app.request({
      url: api.default.cardmoren,
      data: {
        uid: wx.getStorageSync('uid'),
        id: _id,
      },
      success: function (e) {
        if (e.data == 1) {

          wx.showModal({
            title: '提示',
            content: '设置成功',
            showCancel: false,
            success: function () {
              that.mylist();
            }
          })
        } else {
          wx.showModal({
            title: '提示',
            content: '设置失败',
            showCancel: false
          })
        }

      }
    })

  },
  onLoad:function(){
    var that = this;
    that.setData({
      icons: wx.getStorageSync('site') + '/addons/sd_liferuning/tp/public/uploads/background',
    })
  },
  del: function (e) {
    var that = this;
    var _id = e.currentTarget.dataset.id;
    wx.showModal({
      title: '提示',
      content: '您确定删除吗',
      success: function (e) {
        if (e.confirm == 1) {
          app.request({
            url: api.card.del,
            data: {
              id: _id
            },
            success: function (e) {
              that.mylist();
            }
          })
        }
      }
    })
  }
})